package com.example.heimaplayer.base

import android.app.Activity
import android.os.Bundle
import android.os.PersistableBundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.example.heimaplayer.ui.activity.MainActivity
import org.jetbrains.anko.AnkoLogger
import org.jetbrains.anko.debug
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast

//所有app的基类
abstract class BaseActivity:AppCompatActivity(),AnkoLogger {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(getLayoutId())
        initListener()
        initData()
//        debug { "哈哈哈" }

    }
//初始化数据
    open protected fun initData() {

    }

//    adapter listener
    open protected fun initListener() {

    }

    abstract fun getLayoutId():Int

    protected fun myToase(msg:String){
        runOnUiThread { toast(msg) }
    }
//    开启一个activity 并且finish当前的
    inline fun <reified T : Activity>starActivityAndFinish(){
        startActivity<T>()
        finish()
    }
}